package test.util;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;

import org.apache.commons.lang.StringUtils;

public class NumberUtils {
	
	public static BigDecimal stringToBigDecimal(String s) {
		
		BigDecimal bd = null;
		
		try {
			bd = new BigDecimal(s);
			s = new DecimalFormat("###.##").format(bd);
			bd = new BigDecimal(s);
		} catch(Exception e) {
			e.printStackTrace();
			return new BigDecimal(0);
		}
		
		return bd;
	}
	
	public static void main(String args[]) {
		
		String revenue_s = "$1234567890.12345";
		
		revenue_s = StringUtils.remove(revenue_s, "$");
		
		System.out.println(stringToBigDecimal(revenue_s));

	}
}
